package nyist.media.vo;

import lombok.Data;
import nyist.media.entity.ApplyRecord;
import nyist.media.entity.ClassRoom;
import nyist.media.entity.admin.Admin;
import nyist.media.enums.ApplyStatus;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author dcf
 * @date 2019/3/17
 */

@Data
public class ApplyRecordVO {

    /**
     * 申请单ID
     */
    private Long id;

    /**
     * 申请人
     */
    private String applyName;

    /**
     * 申请时间
     */
    private String applyTime;

    /**
     * 归还时间
     */
    private String returnTime;

    /**
     * 申请的教室
     */
    private String roomNo;

    /**
     * 申请单的状态
     */
    private String status;

    /**
     * 是否逾期归还
     */
    private String overDue;

    public ApplyRecordVO(ApplyRecord applyRecord) {
        this.applyName = applyRecord.getAdmin().getUsername();
        this.applyTime = applyRecord.getApplyTime();
        this.id = applyRecord.getId();
        this.overDue = applyRecord.getOverDue() ? "逾期归还" : "按时归还";
        this.returnTime = applyRecord.getReturnTime();
        this.roomNo = applyRecord.getRoom().getRoomNo();
        if (applyRecord.getStatus().equals(ApplyStatus.APPLYING)) {
            this.status = "申请中";
        } else if (applyRecord.getStatus().equals(ApplyStatus.APPLY_PASSED)) {
            this.status = "申请成功";
        } else {
            this.status = "申请失败";
        }
    }
}
